package com.example.rmation.utils;

import org.apache.tomcat.util.codec.binary.Base64;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * 描述：      MD5工具-对密码进行加密
 */
public class MD5Utils {

    public static String getMD5Str(String strValus) throws NoSuchAlgorithmException {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        //加盐处理
        return Base64.encodeBase64String(md5.digest((strValus+ "AbC#.80").getBytes()));
    }

    //测试
    public static void main(String[] args) {
        String md5 = null;
        try {
            md5 = getMD5Str("123456");
            System.out.println(md5);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
    }
}
